using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace Scurvy.Media
{
    public class VideoInMemoryReader : ContentTypeReader<Video>
    {
        protected override Video Read(ContentReader input, Video existingInstance)
        {
            if (existingInstance != null)
            {
                return existingInstance;
            }

            double frameRate = input.ReadDouble();
            int frameCount = input.ReadInt32();
            VideoInMemory vid = new VideoInMemory(frameCount, frameRate);

            for (int i = 0; i < frameCount; i++)
            {
                vid.Add(input.ReadObject<Texture2D>());
            }

            return vid;
        }
    }
}
